<?php
include('../../__global.php');

class aj_editCollection extends ml_controller {

    private $uid;
    private $name;
    private $descrip;
    private $col_id;

    function initParam() {

        $this->name = $this->input('name', 'P');//改成post
        $this->descrip = $this->input('description', 'P');//改成post
        $this->col_id = $this->input('col_id', 'P');//改成post
        $this->uid=$this->__visitor['uid'];
        
    }

    function checkParam() {

        $this->check_referer();
        if ($this->check_permission(ML_PERMISSION_LOGOUT_ONLY)) {
            $this->api_output(ML_RCODE_NOLOGIN);
        }

        if ($this->check_permission(ML_PERMISSION_UNVERIFY_ONLY)) {
            $this->api_output(ML_RCODE_NOACTIVE);
        }

        if (!ml_tool_isuid::is_mluid($this->uid)) {
            $this->api_output(ML_RCODE_PARAM,'','wrong uid');
        }
        if (empty($this->name)||Tool_string::str_width($this->name)>40) {
            $this->api_output(ML_RCODE_PARAM,'','wrong name');
        }
        if (Tool_string::str_width($this->descrip)>400) {
            $this->api_output(ML_RCODE_PARAM,'','descrip too long');
        }

    }

    public function main() {

        $model=new ml_model_dbCollectionBox();
        $rs=$model->editCollection($this->uid,$this->col_id, $this->name, $this->descrip);
        if(!$rs){
            $this->api_output(ML_RCODE_FAIL,'','fail');
        }
        else{
            $this->api_output(ML_RCODE_SUCC);

        }
    }

}

new aj_editCollection();